<?php
error_reporting(E_ALL);
        //ERROR | E_PARSE | E_NOTICE);
require_once 'class/meta/DB.php';
require_once 'class/lib/exportableObject.php';
require_once 'class/meta/Parser.php';
require_once 'class/meta/Pipeline.php';
require_once 'class/meta/Ticker.php';
$requestObject=null;
$id=null;
try{	
	// Get the request parameters and try parse it.
	// The request object will try authenticate the user
	// In the end the request object will contain an user and a command list
	$requestObject=Parser::jsonRequest($_REQUEST);
	$id=$requestObject->player->charId;
	//Sending commands to the pipeline
	Pipeline::addCommands($id,$requestObject->commands);
	//Run commands
	Ticker::tick();
    //Return the char id to the message system
    MessageSystem::setUser($id);
} catch (Exception $e) {
	MessageSystem::addErrorMessage('Error: '.$e->getMessage());
}
// Send the response
Parser::sendResponse($requestObject);
?>